package org.itark.bbs.common.exception;

import cn.hutool.http.server.HttpServerRequest;
import lombok.extern.slf4j.Slf4j;
import org.itark.bbs.common.api.RestResult;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author ：lishenglei
 * @date ：Created in 2021/6/30 18:07
 * @description：
 */
@Slf4j
@ControllerAdvice
public class GlobalExceptionHandle {


    @ResponseBody
    @ExceptionHandler(value = Exception.class)
    public Object myExceptionHandle(HttpServerRequest request, Exception ex) {

        return RestResult.failed(ex.getMessage(), null);
    }

}
